﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.SheepMarkCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMarkHandler
{
    public class SheepMarkSelectCommandHandler :IRequestHandler<SheepMarkSelectCommand,Results<Domain.DTO.Output.PageOutput<SheepMark>>>
    {
        private readonly ISheepMarkService _sheepMarkService;
        private readonly IMapper _mapper;

        public SheepMarkSelectCommandHandler(ISheepMarkService sheepMarkService, IMapper mapper)
        {
            _sheepMarkService = sheepMarkService;
            _mapper = mapper;
        }
        /// <summary>
        /// 戴标列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<Domain.DTO.Output.PageOutput<SheepMark>>> Handle(SheepMarkSelectCommand request, CancellationToken cancellationToken)
        {
            return Results<Domain.DTO.Output.PageOutput<SheepMark>>.DataResult(await _sheepMarkService.GetSheepMarks(request.PageIndex, request.PageSize, request.OverBit, request.ElEarTag, request.NewElEarTag, request.TaggingReason, request.LabeledState));
        }

    }
}
